Rustler Precompiled
philss/rustler_precompiled: Use precompiled NIFs from trusted sources in your Elixir code
Rustlerの上に、利用者がRustコンパイラを用意しないで良くなるように規約を決めたもの。
パッケージ開発者がやること
Rustのコードをクロスコンパイルする
成果物のバイナリを特定のURLで公開する
hexにチェックサムを含めて公開する
Rustler Precompiledが利用されたパッケージを利用しようとすると
環境にあったバイナリがダウンロードされる
チェックサムの検証がされる
precompileされたバイナリが使われる
この結果、パッケージ利用者はRustコンパイラも不要になるし、Rustのコンパイル時間も無くなる。
ビルド環境がシンプルに保てて良い。
使用例はphilss/rustler_precompilation_exampleを見るのが良さそう。
特にGitHub Actionsでの設定はrustler_precompilation_example/release.yml at main · philss/rustler_precompilation_example
実際に使われている例
rusterlium/html5ever_elixir: NIF wrapper of html5ever using Rustler
elixir-nx/explorer: Dataframes for Elixir
Zennに記事を書いた。
ElixirからRustが使い易くなった話